package com.seguriapp.util;

import android.content.Context;
import android.content.SharedPreferences;

public class AppPrefences {

	private static final String PREF_FILE = "seguriapp";
	private static final String USER_NAME = "username";
	private static final String USER_LASTNAME = "userlastname";
	private static final String USER_ADDRESS = "userdirection";
	private static final String USER_AGE = "userage";
	private static final String USER_PHONE = "userphone";
	private static final String USER_SEX = "usersex";
	private static final String USER_MAIL = "usermail";
	private static final String USER_DNI = "userdni";
	private static final String WELCOME_DIALOG = "welcomedialog";
	private static final String ZOOM_LEVEL = "zoomLevel";
	private static final String FIRST_ACCESS = "firstAccess";
	private static final String INITIAL_DATA = "initialData";
	private static final String ALWAYS_GPS = "alwaysgps";
	private static final String ALWAYS_TW = "alwaystw";
	private static final String ALWAYS_FB = "alwaysfb";
	private static final String BIRTHDAY = "birthday";

	private transient final SharedPreferences settings;
	public transient Context mContext;

	public AppPrefences(final Context context) {
		mContext = context;
		settings = context
				.getSharedPreferences(PREF_FILE, Context.MODE_PRIVATE);
	}

	public String getUserName() {
		return settings.getString(USER_NAME, null);
	}

	public void setUserName(final String name) {
		final SharedPreferences.Editor editor = settings.edit();
		editor.putString(USER_NAME, name);
		editor.commit();
	}

	public String getUserLastName() {
		return settings.getString(USER_LASTNAME, null);
	}

	public void setUserLastName(final String lastName) {
		final SharedPreferences.Editor editor = settings.edit();
		editor.putString(USER_LASTNAME, lastName);
		editor.commit();
	}

	public String getUserAddress() {
		return settings.getString(USER_ADDRESS, null);
	}

	public void setUserAddress(final String address) {
		final SharedPreferences.Editor editor = settings.edit();
		editor.putString(USER_ADDRESS, address);
		editor.commit();
	}

	public String getUserPhone() {
		return settings.getString(USER_PHONE, null);
	}

	public void setUserPhone(final String phone) {
		final SharedPreferences.Editor editor = settings.edit();
		editor.putString(USER_PHONE, phone);
		editor.commit();
	}

	public int getUserAge() {
		return settings.getInt(USER_AGE, -1);
	}

	public void setUserAge(final int age) {
		final SharedPreferences.Editor editor = settings.edit();
		editor.putInt(USER_AGE, age);
		editor.commit();
	}

	public String getUserSex() {
		return settings.getString(USER_SEX, null);
	}

	public void setUserSex(final String sex) {
		final SharedPreferences.Editor editor = settings.edit();
		editor.putString(USER_SEX, sex);
		editor.commit();
	}

	public boolean isWelcomeDialogShowed() {
		return settings.getBoolean(WELCOME_DIALOG, false);
	}

	public void setWelcomeDialogShowed(final boolean isdialog) {
		final SharedPreferences.Editor editor = settings.edit();
		editor.putBoolean(WELCOME_DIALOG, isdialog);
		editor.commit();
	}

	public String getUserMail() {
		return settings.getString(USER_MAIL, null);
	}

	public void setUserMail(final String mail) {
		final SharedPreferences.Editor editor = settings.edit();
		editor.putString(USER_MAIL, mail);
		editor.commit();
	}

	public String getUserDni() {
		return settings.getString(USER_DNI, null);
	}

	public void setUserDni(final String dni) {
		final SharedPreferences.Editor editor = settings.edit();
		editor.putString(USER_DNI, dni);
		editor.commit();
	}

	public int getZoomLevel() {
		return settings.getInt(ZOOM_LEVEL, 20);
	}

	public void setZoomLevel(final int zomm) {
		final SharedPreferences.Editor editor = settings.edit();
		editor.putInt(ZOOM_LEVEL, zomm);
		editor.commit();
	}

	public boolean isFirstAccess() {
		return settings.getBoolean(FIRST_ACCESS, false);
	}

	public void setFirstAccess(final boolean first) {
		final SharedPreferences.Editor editor = settings.edit();
		editor.putBoolean(FIRST_ACCESS, first);
		editor.commit();
	}

	public boolean isInitialData() {
		return settings.getBoolean(INITIAL_DATA, false);
	}

	public void setInitialData(final boolean first) {
		final SharedPreferences.Editor editor = settings.edit();
		editor.putBoolean(INITIAL_DATA, first);
		editor.commit();
	}

	public boolean isAlwaysGps() {
		return settings.getBoolean(ALWAYS_GPS, false);
	}

	public void setAlwaysGps(final boolean always) {
		final SharedPreferences.Editor editor = settings.edit();
		editor.putBoolean(ALWAYS_GPS, always);
		editor.commit();
	}

	public boolean isAlwaysFb() {
		return settings.getBoolean(ALWAYS_FB, false);
	}

	public void setAlwaysFb(final boolean always) {
		final SharedPreferences.Editor editor = settings.edit();
		editor.putBoolean(ALWAYS_FB, always);
		editor.commit();
	}

	public boolean isAlwaysTw() {
		return settings.getBoolean(ALWAYS_TW, false);
	}

	public void setAlwaysTw(final boolean always) {
		final SharedPreferences.Editor editor = settings.edit();
		editor.putBoolean(ALWAYS_TW, always);
		editor.commit();
	}
	public String getUserBirthday() {
		return settings.getString(BIRTHDAY, null);
	}

	public void setUserBirthday(final String name) {
		final SharedPreferences.Editor editor = settings.edit();
		editor.putString(BIRTHDAY, name);
		editor.commit();
	}

}
